<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>directive</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <style>
        .pos{
            position: absolute;
        }
    </style>
</head>
<body>
    <div id="root"></div>
    <script>
        

        const directive=('pos' ,(el,binding)=>{
                el.style[binding.arg]=binding.value+'px'
                console.log(binding.arg)
            } 
        )
        const app=Vue.createApp({
            data(){
                return{
                    distance:100
                }
            },
            directives:['directive'],
            template:`<div v-pos:left="distance" class='pos'>
                    <input/>
                </div>`
        })
        // app.directive('pos' ,{
        //     mounted(el,binding){
        //         el.style[binding.arg]=binding.value+'px'
        //         console.log(binding.arg)
        //     }
        // })

        app.mount('#root')
    </script>
</body>
</html>